package org.jackysoft.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.jackysoft.annotations.BID;
import org.jackysoft.util.MySqlSchema;

@SuppressWarnings("serial")
@Entity
@Table(schema=MySqlSchema.Businessbase)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class FieldAccess extends AbstractNoIdEntity implements AppendinceItem  {

	private FieldAccessPK id;

	private Set<String> readonly = new HashSet<String>();

	
	public FieldAccess() {
		super();
		
	}

	public FieldAccess(String workflowName,Long stepId){
		if(id ==null) id = new FieldAccessPK(workflowName,stepId);
		else {
			id.setWorkflowName(workflowName);
			id.setStepId(stepId);
		}
	}
	
	/**
	 * 返回该表单模板该步骤中只读元素的name值
	 * 例如:<br>
	 * <code>
	 * &lt;input type='text' readonly='true' name='username'/&gt;
	 * </code><br>
	 * 则把此控件的name值加进此set
	 * */
	@ElementCollection(
			targetClass=java.lang.String.class
			
	)
	@CollectionTable(schema=MySqlSchema.Businessbase)
	@Column(name="element_name")
	public Set<String> getReadonly() {
		return readonly;
	}

	/**
	 * @param readonlyFields
	 *            要设置的 readonlyFields
	 */
	public void setReadonly(Set<String> readonly) {
		this.readonly = readonly;
	}

	@Id@BID
	public FieldAccessPK getId() {
		return id;
	}

	public void setId(FieldAccessPK pk){
		this.id = pk;
	}

	
	

}
